from flask import Blueprint, request
from utilsapp.mysql_con import  db_insert, db_pagelist,db_delete


bluePrint = Blueprint('log', __name__)
tableName = 'log'



# 分页查询
@bluePrint.route('/getlist', methods=["post"])
def table_list():
    sql = "SELECT * from log ORDER BY create_time desc"
    j = db_pagelist(sql, request.json['page'])
    return j


@bluePrint.route('/delete', methods=["post"])
def log_delete():
    id = request.json['id']
    return db_delete(tableName, f'WHERE id=%s', {'id': id})

@bluePrint.route('/add', methods=['POST'])
def log_add():
    return db_insert(tableName, request.json)
